package com.zj.common.util;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;

public class FileUtil {
	public static void readFile(InputStream inputStream) throws IOException {
		InputStreamReader isr = new InputStreamReader(inputStream, "GBK");
		BufferedReader br = new BufferedReader(isr);
		String line = "";
		int a= 0;
		while ((line = br.readLine()) != null) {
			a=a+Integer.valueOf(line.trim());
		}
		System.out.println(a);
	}

	public static void createFile(String[] strs, OutputStream fos) throws Exception {

		OutputStreamWriter osw = new OutputStreamWriter(fos, "GBK");
		BufferedWriter bw = new BufferedWriter(osw);
		for (String arr : strs) {
			bw.write(arr);
			bw.newLine();
		}
		// 注意关闭的先后顺序，先打开的后关闭，后打开的先关闭
		bw.close();
		osw.close();
		fos.close();
	}
	
	public static void main(String[] args) throws Exception {
    	File file = new File("E:/eoc.txt");		
		readFile(new FileInputStream(file));
	}
}
